const router = require('koa-router')()
const user = require('../api/user')
router.prefix('/user')
//  tags 可以理解成借口分类  parameters 参数
// #region
/**
 * @swagger
 * /user/login 用户登录:
 *   post:
 *     description: 用户登录
 *     tags: [用户模块]
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: phone
 *         description: 用户账号
 *         in: formData
 *         required: true
 *         type: string
 *       - name: password
 *         description: 用户密码
 *         in: formData
 *         required: true
 *         type: string
 *       - name: captcha
 *         description: 验证码
 *         in: formData
 *         required: true
 *         type: string
 *     responses:
 *       0:
 *         description: 登入成功
 *         schema:
 *           type: object
 *           $ref: '#/definitions/success'
 *       -1:
 *         description: 登入失败
 *         schema:
 *           type: object
 *           $ref: '#/definitions/fail'
 */
// #endregion
router.post('/login', user.login)
// #region
/**
 * @swagger
 * /user/register 用户注册:
 *   post:
 *     description: 用户注册
 *     tags: [用户模块]
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: phone
 *         description: 手机号（登陆账号）
 *         in: formData
 *         required: true
 *         type: string
 *       - name: password
 *         description: 密码
 *         in: formData
 *         required: true
 *         type: string
 *       - name: email
 *         description: 邮箱地址
 *         in: formData
 *         required: true
 *         type: string
 *       - name: code
 *         description: 邮箱验证码
 *         in: formData
 *         required: true
 *         type: string
 *     responses:
 *       0:
 *         description: 成功
 *         schema:
 *           type: object
 *           $ref: '#/definitions/success'
 *       -1:
 *         description: 失败
 *         schema:
 *           type: object
 *           $ref: '#/definitions/fail'
 */
// #endregion
router.post('/register', user.register)
// #region
/**
 * @swagger
 * /user/resetPass 重置密码（找回密码）:
 *   post:
 *     description: 重置密码（找回密码）
 *     tags: [用户模块]
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: email
 *         description: 邮箱地址
 *         in: formData
 *         required: true
 *         type: string
 *       - name: password
 *         description: 新的密码
 *         in: formData
 *         required: true
 *         type: string
 *       - name: code
 *         description: 邮箱验证码
 *         in: formData
 *         required: true
 *         type: string
 *     responses:
 *       0:
 *         description: 成功
 *         schema:
 *           type: object
 *           $ref: '#/definitions/success'
 *       -1:
 *         description: 失败
 *         schema:
 *           type: object
 *           $ref: '#/definitions/fail'
 */
// #endregion
router.post('/resetPass', user.resetPass)
// #region
/**
 * @swagger
 * /user/getInfo 获得用户信息:
 *   get:
 *     description: 获得用户信息
 *     tags: [用户模块]
 *     responses:
 *       0:
 *         description: 成功
 */
// #endregion
router.get('/getInfo', user.getInfo)
// #region
/**
 * @swagger
 * /user/modify 修改用户信息（传什么字段修改什么）:
 *   post:
 *     description: 修改用户信息（传什么字段修改什么）
 *     tags: [用户模块]
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: userName
 *         description: 店铺名称
 *         in: formData
 *         required: true
 *         type: string
 *       - name: avatar
 *         description: 店铺头像（传上传图片后返回的id）
 *         in: formData
 *         required: true
 *         type: string
 *       - name: descText
 *         description: 店铺介绍
 *         in: formData
 *         required: true
 *         type: string
 *     responses:
 *       0:
 *         description: 成功
 *         schema:
 *           type: object
 *           $ref: '#/definitions/success'
 *       -1:
 *         description: 失败
 *         schema:
 *           type: object
 *           $ref: '#/definitions/fail'
 */
// #endregion
router.post('/modify', user.modify)
router.post('/modifyAccount', user.modifyAccount)
// 刷新token
router.get('/refreshToken', user.refreshToken)
module.exports = router
